﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace _25_使用Lambda表达式动态产生数据_委托与事件
{
    class Program
    {
        static void Main(string[] args)
        {
            DataManage dm = new DataManage(() => new Dictionary<int, string>
            {
                [1] = "windows",
                [2] = "hose",
                [3] = "kite",
                [4] = "noodles",
                [5] = "claim"
            });

            //输出字典集合中的数据，使用DispalyData
            dm.DisplayData();
        }
    }

    public class DataManage
    {
        IDictionary<int, string> _dicData;

        public DataManage(Func<IDictionary<int, string>> data)
        {
            _dicData = data();
        }

        public void DisplayData()
        {
            Console.WriteLine("------- 数据列表 ------");
            foreach (var kp in _dicData)
            {
                Console.WriteLine($"{kp.Key,4}\t{kp.Value}");
            }
        }
    }
}
